// This file contains the definition of all unary defined functions such as sin
// or cos plus the definition of the binary operators such as + or /.
package funcparser

import "math"

type unaryFunc func(float64) float64
type binaryFunc func(float64, float64) float64

// why doesn't 'const' work?
var (
	funcs = map[string]unaryFunc{
		"abs":  math.Abs,
		"sin":  math.Sin,
		"cos":  math.Cos,
		"-":    func(x float64) float64 { return -x },
		"sqrt": math.Sqrt,
	}

	binops = map[string]binaryFunc{
		"+": func(a, b float64) float64 { return a + b },
		"-": func(a, b float64) float64 { return a - b },
		"*": func(a, b float64) float64 { return a * b },
		"/": func(a, b float64) float64 { return a / b },
		"%": func(a, b float64) float64 { return math.Mod(a, b) },
	}
)
